package com.vzaar.examples;

import com.vzaar.AccountType;
import com.vzaar.Vzaar;
import com.vzaar.VzaarException;

/**
 * Example of getting account type details. 
 * 
 * @author Marc G. Smith
 */
public class AccountTypeExample 
{
	///////////////////////////////////////////////////////////////////////////
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			ParameterHelper helper = new ParameterHelper(args);
			args = helper.getRemainingArgs();
			if(args.length != 1) {
				printUsage();
				System.exit(1);
				return;
			}

			Vzaar vzaar = helper.createVzaar();
			AccountType account = vzaar.getAccountType(Integer.parseInt(args[0]));
			System.out.println("Account Id:       " + account.getAccountId());
			System.out.println("Title:            " + account.getTitle());
			System.out.println("Monthly:          " + account.getMonthly());
			System.out.println("Currency:         " + account.getCurrency()); 
			System.out.println("Bandwidth:        " + account.getBandwidth());
			System.out.println("Borderless:       " + (account.isBorderless() ? "Yes" : "No"));
			System.out.println("Search Enhancer:  " + (account.isSearchEnhancer() ? "Yes" : "No"));
		}
		catch(VzaarException e) {
			System.err.println("Error: " + e.getMessage());
			System.exit(2);
		}
		catch(ArrayIndexOutOfBoundsException e) {
			printUsage();
			System.exit(1);
		}
		catch(NumberFormatException e) {
			printUsage();
			System.exit(1);
		}
	}
	
	///////////////////////////////////////////////////////////////////////////

	private static final  void printUsage() {
		System.out.println("Usage: vzaar-account " +
			ParameterHelper.getCommonCommandLineArgs() + " <accountType>\n");
		System.out.println("Params:");
		System.out.println("   <accountType>       " +
			"The account type id");
		System.out.println(ParameterHelper.getCommonCommandLineHelp());
	}

	///////////////////////////////////////////////////////////////////////////
}
